package com.yingsheng.bi.hks.mapping;

import com.yingsheng.bi.hks.basic.PUser;
import com.yingsheng.bi.hks.dto.user.UserLoginRes;
import com.yingsheng.bi.hks.repository.dao.po.Role;
import com.yingsheng.bi.hks.repository.dao.po.Users;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;


@Mapper
public interface LoginMappings {

    LoginMappings INSTANCE = Mappers.getMapper(LoginMappings.class);

    @Mappings(value = {
            @Mapping(source = "id", target = "userId"),
            @Mapping(source = "type", target = "userType"),
            @Mapping(source = "name", target = "userName"),
            @Mapping(source = "state", target = "userState"),
            @Mapping(source = "cname", target = "name")
    })
    UserLoginRes userPo2LoginRes(PUser users);

    @Mappings(value = {
            @Mapping(source = "users.id", target = "id"),
            @Mapping(source = "users.type", target = "type"),
            @Mapping(source = "users.name", target = "name"),
            @Mapping(source = "role.id", target = "roleId"),
            @Mapping(source = "role.type", target = "roleType"),
            @Mapping(source = "role.name", target = "roleName")
    })
    PUser userAndRolePo2PUser(Users users, Role role);

}
